using Coding4Fun.Phone.Controls;
using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Network;
using MicroMsg.Protocol;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.Scene.Image;
using MicroMsg.Scene.Voice;
using MicroMsg.Storage;
using MicroMsg.UI.ImageFilter;
using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;
using Microsoft.Xna.Framework.Media;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace MicroMsg.UI.UserContrl
{
	public class ChatPageCtrl : UserControl
	{
		private const string TAG = "ChatPage";
		private const int VoiceView = 1;
		private const int TxtView = 0;
		private const int cNSmileyHeight = 455;
		private const int cNSmileyContentHeight = 455;
		private const int OldListHeight = 604;
		private const int OldSmileyHeight = 455;
		private const long MIN_NEW_MSG_TIPS_DISPLAY_TIME = 2000L;
		private IChatContainerPage containerPage;
		private bool isFromShareContent;
		private string strShareContentToken = "";
		private int unReadMsgCount;
		private string newRecvMsgContent;
		private long lastShowNewMsgTipTime;
		private int newRecvMsgNum;
		public EmojiListCtrl mEmojiListCtrl;
		public ChatEggsCtrl mChatEggsCtrl;
		private bool isSendEnable = true;
		private ScrollViewer chatListScroll;
		private bool isResumeError;
		private bool isHasFly;
		public ApplicationBar mBar;
		private MMObservableCollection<ChatMsg, ChatListItem> mDataList = new MMObservableCollection<ChatMsg, ChatListItem>();
		private Button ShowMoreBtn;
		private Visibility showMoreVisbility = 1;
		public string cuUser;
		public string qqShowName;
		private bool isNewChatpage;
		private EventWatcher mPicSendingWatcher;
		private EventWatcher mPicSendCompleteWatcher;
		private static Dictionary<int, int> ProgressDic;
		private MMMessageBox mmmessageBox_0;
		private ImageConfirmControl mImageConfirmControl;
		private VoiceService mVoiceService;
		private ChatAppMsgMusicItem mChatAppMsgMusicItem;
		private bool isMMMediaPlayerInit;
		private ChatInputMode mCuInputMode = ChatInputMode.InputDefault;
		private bool mIsDelayShowSmiley;
		private double mSipHeight;
		private EventWatcher mChatRoomChangeWatcher;
		private bool isInitChatRoomChange;
		private EventWatcher mWatcherSceneAddContactEvent;
		private string oldTxt;
		private int oldchatstatus;
		private EventWatcher mQQPwdWatcher;
		private EventWatcher mQQPwdVerifyWatcher;
		private ChatMsg tmpChatmsg;
		private int trasnID;
		private string imgSid;
		private byte[] imgBuf;
		private EventWatcher mWatchMsgChange;
		private EventWatcher mWatchBGChange;
		private object mObjectWatcher;
		private MenuItem changeBGItem;
		public ContextMenu menu;
		public bool bIsChatListLayoutHold;
		private RoundButton ExtraActionBtn;
		private bool mBIsInputerInited;
		private bool mIsInputInited;
		private bool bFromAtMemberDelegate;
		private bool isInputFocus;
		private bool isVoiceRecordStart;
		private bool mBIsExtraActionCancled;
		public bool IsStartCompleted;
		public List<CustomSmileyItem> playingGifList;
		public List<int> allCustomSmileyIds;
		public long LastGifTime;
		internal Grid LayoutRoot;
		internal Grid RootGrid;
		internal Grid ChatTitle;
		internal StackPanel TitleArea;
		internal EmojiText PageTitle;
		internal TextBlock ChatNumTitle;
		internal CommonImageButton PeopleListBtn;
		internal Grid QQChatTitle;
		internal StackPanel QQTitleArea;
		internal Image QQLogo;
		internal EmojiText QQPageTitle;
		internal CommonImageButton PeopleDetailBtn;
		internal Grid gridNoFmessageTip;
		internal MediaElement MMAudioPlayer;
		internal MediaElement MMMediaPlayer;
		internal Grid ChatPanelRoot;
		internal Grid ChatListLayout;
		internal MMListBox ChatList;
		internal StackPanel FootArea;
		internal MMInputer mInputer;
		internal ExtralChatButton mExtralChatButton;
		internal Grid newMsgTips;
		internal SmileyText content;
		internal TextBlock total;
		internal Grid tooMuchMsgTips;
		internal Grid tooMuchMsgTipsGrid;
		internal Button closeTooMuchMsgTips;
		private bool _contentLoaded;
		public bool IsEmojiListCtrlExist
		{
			get
			{
				return this.mEmojiListCtrl != null;
			}
		}
		public ChatPageCtrl()
		{
			MMTheme.GetInstance().DelayInitThemes();
			this.InitializeComponent();
			VoiceService.ClearReceived();
			this.PlayVoiceInit();
			base.add_Loaded(new RoutedEventHandler(this.ChatPage_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.ChatPage_Unloaded));
			this.ChatList.LoadedComplete += new RoutedEventHandler(this.ChatList_LoadedComplete);
			this.mExtralChatButton.ShareLocationButtonClick += new RoutedEventHandler(this.mExtralChatButton_ShareLocationButtonClick);
			this.mExtralChatButton.CameraButtonClick += new RoutedEventHandler(this.mExtralChatButton_CameraCardClick);
			this.mExtralChatButton.PicButtonClick += new RoutedEventHandler(this.mExtralChatButton_PicButtonClick1);
			this.mExtralChatButton.ShareCardClick += new RoutedEventHandler(this.mExtralChatButton_ShareCardClick);
			this.CreatMenu();
		}
		public bool isShowByChatContainerPage()
		{
			bool result = false;
			if (this.containerPage != null && this.containerPage.HasChatPageShow())
			{
				result = true;
			}
			return result;
		}
		private void initNewMsgTipsCallBack()
		{
			MMListBox.onListFarFromBottom = new MMListBox.OnListFarFromBottom(this.MsgListFarFromBottom);
			this.newRecvMsgContent = null;
			this.newRecvMsgNum = 0;
		}
		private void clearNewMsgTipsCallBack()
		{
			MMListBox.onListFarFromBottom = null;
			this.newRecvMsgContent = null;
			this.newRecvMsgNum = 0;
		}
		private void MsgListFarFromBottom(bool bool_0)
		{
			if (bool_0)
			{
				this.showNewMsgTips(this.newRecvMsgContent, this.newRecvMsgNum);
			}
			this.newRecvMsgContent = null;
			this.newRecvMsgNum = 0;
		}
		public void recordNewMsgContent(string content, int int_0)
		{
			if (content != null)
			{
				content = content.Replace('\n', ' ');
				content = content.Replace('\r', ' ');
			}
			this.newRecvMsgContent = content;
			this.newRecvMsgNum = int_0;
		}
		public void showNewMsgTips(string msgContent, int int_0)
		{
			if (this.tooMuchMsgTips.get_Visibility() == null)
			{
				return;
			}
			if (this.mExtralChatButton.IsShowing())
			{
				return;
			}
			if (msgContent == null)
			{
				return;
			}
			this.newMsgTips.set_Visibility((this.content != null) ? 0 : 1);
			this.total.set_Visibility((int_0 < 2) ? 1 : 0);
			int num = (int_0 > 99) ? 99 : int_0;
			this.total.set_Text(string.Format(strings.Chat_Page_New_Msg_Tips, num));
			this.content.Text = msgContent;
			this.lastShowNewMsgTipTime = DebugEx.getTimeSpan(0L);
		}
		private void hideNewMsgTips()
		{
			this.newMsgTips.set_Visibility(1);
		}
		private void showNewMsgTipsTap(object sender, RoutedEventArgs e)
		{
			this.ScrollToLast();
			this.newRecvMsgContent = null;
			this.newRecvMsgNum = 0;
		}
		private void InitBinding(bool isQQChat)
		{
			this.setBackground();
			this.RootGrid.set_Margin((Thickness)Application.get_Current().get_Resources().get_Item("PageMargin"));
			if (!isQQChat)
			{
				this.PageTitle.Foreground = R.theme.CHAT_TITLE_BRUSH;
				this.ChatNumTitle.set_Foreground(R.theme.CHAT_TITLE_BRUSH);
				this.ChatNumTitle.set_FontFamily((FontFamily)Application.get_Current().get_Resources().get_Item("PhoneFontFamilySemiLight"));
				return;
			}
			this.QQLogo.set_Source(new ImageSourceConverter().ConvertFromString(R.theme.plugin_qqoffline_chatmain_qqlogo) as ImageSource);
			this.QQPageTitle.Foreground = R.theme.CHAT_TITLE_BRUSH;
			this.PeopleDetailBtn.ImgSource = (new ImageSourceConverter().ConvertFromString(R.theme.plugin_qqoffline_chatmain_people) as ImageSource);
		}
		private void setBackground()
		{
			BitmapImage backGround = ConversationMgr.getBackGround(this.cuUser);
			if (backGround == null)
			{
				backGround = ConversationMgr.getBackGround("DEFAULT_BACKGROUND_USER_NAME");
			}
			if (backGround == null)
			{
				this.LayoutRoot.set_Background(R.theme.CHAT_BK_BRUSH);
				return;
			}
			ImageBrush imageBrush = new ImageBrush();
			imageBrush.set_ImageSource(backGround);
			this.LayoutRoot.set_Background(imageBrush);
		}
		public void CheckEmojiListCtrl()
		{
			if (this.mEmojiListCtrl != null)
			{
				return;
			}
			this.mEmojiListCtrl = new EmojiListCtrl();
			this.RootGrid.get_Children().Add(this.mEmojiListCtrl);
		}
		public void CheckChatEggsCtrl()
		{
			if (this.mChatEggsCtrl != null)
			{
				return;
			}
			this.mChatEggsCtrl = new ChatEggsCtrl();
			switch (this.mCuInputMode)
			{
			case ChatInputMode.InputTxtMode:
				this.mChatEggsCtrl.set_Margin(new Thickness(0.0, 400.0, 0.0, 0.0));
				break;
			case ChatInputMode.InputVoiceMode:
				this.mChatEggsCtrl.set_Margin(new Thickness(0.0, 0.0, 0.0, 0.0));
				break;
			case ChatInputMode.InputSmileyMode:
				break;
			case ChatInputMode.InputDefault:
				this.mChatEggsCtrl.set_Margin(new Thickness(0.0, 0.0, 0.0, 0.0));
				break;
			default:
				this.mChatEggsCtrl.set_Margin(new Thickness(0.0, 0.0, 0.0, 0.0));
				break;
			}
			this.RootGrid.get_Children().Add(this.mChatEggsCtrl);
		}
		private void ChatPage_Unloaded(object sender, RoutedEventArgs e)
		{
			this.unRegisterEvent();
			this.ObscuredUnit();
		}
		private void ScrollViewer_Loaded(object sender, RoutedEventArgs e)
		{
			this.chatListScroll = (sender as ScrollViewer);
		}
		public void ScrollToLast()
		{
			this.ChatList.ScrollToLast();
			if (this.mIsInputInited)
			{
				this.hideMsgTips(false);
			}
		}
		public static void BringIntoViewForScrollViewer(FrameworkElement frameworkElement, ScrollViewer scrollViewer)
		{
			if (frameworkElement == null)
			{
				return;
			}
			GeneralTransform generalTransform = null;
			try
			{
				generalTransform = frameworkElement.TransformToVisual(scrollViewer);
			}
			catch (Exception)
			{
				return;
			}
			Point point = generalTransform.Transform(new Point(0.0, 0.0));
			if (point.get_Y() < 0.0 || point.get_Y() > scrollViewer.get_ViewportHeight())
			{
				scrollViewer.ScrollToVerticalOffset(scrollViewer.get_VerticalOffset() + point.get_Y());
			}
		}
		private void ChatPage_Loaded(object sender, RoutedEventArgs e)
		{
			this.registerEvent();
			this.ObscuredInit();
			if (this.bFromAtMemberDelegate)
			{
				this.UpdateTxtByAtMember();
			}
		}
		private ApplicationBar setAppBar()
		{
			ChatContainerPage chatContainerPage = this.containerPage as ChatContainerPage;
			if (this.cuUser != "fmessage")
			{
				this.mBar = null;
				chatContainerPage.set_ApplicationBar(null);
				return null;
			}
			if (this.mBar != null)
			{
				if (!this.mBar.get_IsVisible())
				{
					this.mBar.set_IsVisible(true);
				}
				chatContainerPage.set_ApplicationBar(this.mBar);
				return this.mBar;
			}
			this.mBar = new ApplicationBar();
			this.mBar.set_IsMenuEnabled(true);
			this.mBar.set_IsVisible(true);
			ApplicationBarMenuItem applicationBarMenuItem = new ApplicationBarMenuItem(strings.Set_Plugin_Setting);
			applicationBarMenuItem.add_Click(new EventHandler(this.btnMenu_Click));
			this.mBar.get_MenuItems().Add(applicationBarMenuItem);
			chatContainerPage.set_ApplicationBar(this.mBar);
			BasePage.SetAppBarStyle(this.mBar);
			return this.mBar;
		}
		private void btnMenu_Click(object sender, EventArgs e)
		{
			ToolFunction.GotoPageForUserControl("/Source/UI/Contact/FriendsIntroducePluginView.xaml", null, false);
		}
		private void MsgInit()
		{
			Conversation conversation = StorageMgr.converation.method_0(this.cuUser);
			if (conversation != null)
			{
				this.unReadMsgCount = conversation.nUnReadCount;
			}
			this.ChatList.set_ItemsSource(null);
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			this.ChatList.IsAutoToBottom = true;
			this.ChatList.IsLockWhenFarFromBottom = false;
			ChatMsgMgr.attachTalker(this.mDataList, this.cuUser, this);
			if (this.mDataList == null)
			{
				Log.smethod_1("ChatPage", "MsgInit,mDataList == null");
				return;
			}
			this.loadCustomSmileys(this.mDataList);
			this.mDataList.Bind(this.ChatList);
			if (ChatMsgMgr.CanExpand(this.cuUser))
			{
				this.showMoreVisbility = 0;
			}
			else
			{
				this.showMoreVisbility = 1;
			}
			this.RefreshMoreBtn();
			this.showTooMuchMsgTips(this.cuUser);
			this.ClearUnreadCount();
			UITaskManager.DoTaskLater(new UITaskDlg(this.lockFarFromBottom), 1500u);
		}
		private void lockFarFromBottom()
		{
			base.get_Dispatcher().BeginInvoke(delegate
			{
				this.ChatList.IsLockWhenFarFromBottom = true;
			});
		}
		private void ClearUnreadCount()
		{
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			if (ContactHelper.isQContact(this.cuUser))
			{
				QConversation qConversation = StorageMgr.qconv.method_0(this.cuUser);
				if (qConversation == null || qConversation.nUnReadCount <= 0)
				{
					return;
				}
				bool forcetoReaded = true;
				if (this.mDataList != null && this.mDataList.get_Count() != 0)
				{
					ChatMsg chatMsg_ = this.mDataList[this.mDataList.get_Count() - 1];
					if (chatMsg_.IsVoice() && !ChatMsgMgr.getVoiceMsgIsRead(chatMsg_))
					{
						forcetoReaded = false;
					}
					StorageMgr.qconv.setUnreadCount(this.cuUser, 0, forcetoReaded);
					return;
				}
				return;
			}
			else
			{
				if (ContactHelper.isBottleContact(this.cuUser))
				{
					BConversation bConversation = StorageMgr.bconv.method_0(this.cuUser);
					if (bConversation == null || bConversation.nUnReadCount <= 0)
					{
						return;
					}
					bool forcetoReaded2 = true;
					if (this.mDataList != null && this.mDataList.get_Count() != 0)
					{
						ChatMsg chatMsg_2 = this.mDataList[this.mDataList.get_Count() - 1];
						if (chatMsg_2.IsVoice() && !ChatMsgMgr.getVoiceMsgIsRead(chatMsg_2))
						{
							forcetoReaded2 = false;
						}
						BConversationMgr.setUnreadCount(this.cuUser, 0, forcetoReaded2);
						return;
					}
					return;
				}
				else
				{
					Conversation conversation = StorageMgr.converation.method_0(this.cuUser);
					if (conversation == null || conversation.nUnReadCount <= 0)
					{
						return;
					}
					bool forcetoReaded3 = true;
					if (this.mDataList != null && this.mDataList.get_Count() != 0)
					{
						ChatMsg chatMsg_3 = this.mDataList[this.mDataList.get_Count() - 1];
						if (chatMsg_3.IsVoice() && !ChatMsgMgr.getVoiceMsgIsRead(chatMsg_3))
						{
							forcetoReaded3 = false;
						}
						ConversationMgr.setUnreadCount(this.cuUser, 0, forcetoReaded3);
						return;
					}
					return;
				}
			}
		}
		private void MsgUnit()
		{
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			ChatMsgMgr.detachTalker(this.cuUser);
			if (this.mDataList != null)
			{
				this.mDataList.UnBind();
				this.mDataList.Clear();
			}
		}
		private void ShowMoreBtn_Loaded(object sender, RoutedEventArgs e)
		{
			this.ShowMoreBtn = (sender as Button);
			this.RefreshMoreBtn();
		}
		private void ShowMoreBtn_Click(object sender, RoutedEventArgs e)
		{
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			int num = 1;
			ChatMsgMgr.ExpandTalkMsgList(this.cuUser);
			if (ChatMsgMgr.CanExpand(this.cuUser))
			{
				this.showMoreVisbility = 0;
			}
			else
			{
				this.ChatList.Focus();
				this.showMoreVisbility = 1;
				num++;
			}
			this.ChatList.LockScroll(num);
			base.get_Dispatcher().BeginInvoke(delegate
			{
				this.RefreshMoreBtn();
			});
		}
		public void RefreshMoreBtn()
		{
			if (this.ShowMoreBtn == null)
			{
				return;
			}
			if (ChatMsgMgr.CanExpand(this.cuUser))
			{
				this.showMoreVisbility = 0;
			}
			else
			{
				this.showMoreVisbility = 1;
			}
			int expandNum = ChatMsgMgr.GetExpandNum(this.cuUser);
			if (expandNum > 0 && expandNum < 15)
			{
				this.ShowMoreBtn.set_Content(strings.ChatMoreButtonTitle);
			}
			else
			{
				this.ShowMoreBtn.set_Content(strings.ChatMoreButtonTitle);
			}
			this.ShowMoreBtn.set_Visibility(this.showMoreVisbility);
		}
		private void InitUI()
		{
			this.PeopleListBtn.set_Visibility(0);
			this.PageTitle.set_MaxWidth(401.0);
			this.ChatNumTitle.set_Text("");
			this.mVoiceService.Init();
			this.FootArea.set_Visibility(0);
			this.ChatList.set_MaxHeight(616.0);
			this.ChatList.set_Height(604.0);
			this.ChatListLayout.set_Margin(new Thickness(0.0, 0.0, 0.0, 71.0));
			this.QQChatTitle.set_Visibility(1);
			this.ChatTitle.set_Visibility(0);
			this.isSendEnable = true;
			this.initInputer();
			this.ExtraActionBtn.set_IsEnabled(true);
			this.gridNoFmessageTip.set_Visibility(1);
			this.isFromShareContent = false;
			this.strShareContentToken = "";
			base.get_Dispatcher().BeginInvoke(delegate
			{
				this.setAppBar();
				this.setNoFmeessageTip();
			});
			this.PeopleListBtn.set_IsEnabled(true);
			this.ScrollToLast();
			ItemFlyInAndOutAnimations.TitleFlyIn(this.TitleArea);
		}
		private void setNoFmeessageTip()
		{
			if (!(this.cuUser != "fmessage") && FMsgMgr.getMsgNum(FMsgType.other) == 0)
			{
				this.gridNoFmessageTip.set_Visibility(0);
				return;
			}
			this.gridNoFmessageTip.set_Visibility(1);
		}
		private void ShowEasterEggs()
		{
			int msgNum = StorageMgr.chatMsg.getMsgNum(this.cuUser);
			int start = msgNum - this.unReadMsgCount;
			int int_ = this.unReadMsgCount;
			this.unReadMsgCount = 0;
			if (msgNum <= 0)
			{
				return;
			}
			List<ChatMsg> msgList = StorageMgr.chatMsg.getMsgList(this.cuUser, start, int_);
			if (msgList == null)
			{
				return;
			}
			for (int i = msgList.get_Count() - 1; i >= 0; i--)
			{
				if (msgList.get_Item(i) != null && msgList.get_Item(i).IsTxt())
				{
					List<EggItem> containChatEggs = ChatContainerPage.getContainChatEggs(msgList.get_Item(i).strContent);
					if (containChatEggs.get_Count() > 0)
					{
						ChatContainerPage.doChatEggs(containChatEggs, ChatEggsCtrl.EggType.ReceiveEgg);
						return;
					}
				}
			}
		}
		public void OnPageIn(object[] object_0, IChatContainerPage page)
		{
			this.containerPage = page;
			this.containerPage.StartSipListen();
			this.initNewMsgTipsCallBack();
			bool isQQChat = false;
			this.InitUI();
			if (object_0 != null && Enumerable.Count<object>(object_0) != 0)
			{
				string text = object_0[0] as string;
				this.cuUser = text;
				Log.smethod_5("ChatPage", "obj count == " + Enumerable.Count<object>(object_0).ToString());
				if (Enumerable.Count<object>(object_0) == 4 && object_0[3] != null)
				{
					this.isFromShareContent = true;
					this.strShareContentToken = (object_0[3] as string);
					Log.smethod_5("ChatPage", "obj count == " + Enumerable.Count<object>(object_0).ToString() + " " + this.strShareContentToken);
				}
				else
				{
					if (text.EndsWith("@qqim"))
					{
						isQQChat = true;
						List<string> list = new List<string>();
						this.qqShowName = ContactHelper.getDisplayName(text, null);
						string text2 = AccountMgr.getCurAccount().nBindQQ.ToString() + "@qqim";
						list.Add(text2);
						list.Add(text);
						BatchGetContactProfileMgr.batchGetProfile(list);
						this.InitQQChatTitle(this.qqShowName);
						if (!AccountMgr.RecvOfflineQQMsg)
						{
							this.isSendEnable = false;
						}
					}
				}
				this.RefreshMember();
				if (Enumerable.Count<object>(object_0) == 2)
				{
					try
					{
						this.isNewChatpage = (bool)object_0[1];
					}
					catch (Exception)
					{
					}
				}
				if (ContactMgr.IsFmessageUser(this.cuUser))
				{
					this.FootArea.set_Visibility(1);
					this.ChatListLayout.set_Margin(new Thickness(0.0, 0.0, 0.0, 30.0));
					this.ChatList.set_MaxHeight(665.0);
					this.ChatList.set_Height(665.0);
				}
			}
			this.InitBinding(isQQChat);
			this.initInputer();
			this.SendPicInit();
			this.ChatRoomChangeInit();
			ToolFunction.ShowSystemTrayProgressIndicator("");
			base.get_Dispatcher().BeginInvoke(delegate
			{
				this.MsgInit();
				if (this.isFromShareContent)
				{
					this.AutoSendImg(this.strShareContentToken);
				}
				if (this.unReadMsgCount > 0)
				{
					this.ShowEasterEggs();
				}
				base.get_Dispatcher().BeginInvoke(delegate
				{
					ToolFunction.HideSystemTrayProgressIndicator();
				});
			});
			this.StatusSaveInit();
			this.NeedQQPwdInit();
			if (this.changeBGItem != null)
			{
				this.changeBGItem.Header = strings.ChatBackground_Button;
			}
			if (this.mInputer.VoiceSend != null)
			{
				this.mInputer.VoiceSend.set_Content(strings.ChatVoiceNormalText);
			}
			this.mIsInputInited = true;
		}
		public void OnPageOut()
		{
			if (this.ShowMoreBtn != null)
			{
				this.ShowMoreBtn.set_Visibility(1);
			}
			this.SaveToCache();
			this.containerPage.EndSipListen();
			this.clearNewMsgTipsCallBack();
			this.hideMsgTips(false);
			this.MsgUnit();
			this.SendPicUnit();
			this.ChatRoomChangeUnit();
			this.StatusSaveUnit();
			ScreenLockService.Resume();
			this.NeedQQPwdUnit();
			this.mVoiceService.UnInit();
			this.playingGifList.Clear();
			this.ClearMediaPlayer();
			this.mIsInputInited = false;
			if (this.mInputer != null)
			{
				this.mInputer.SwitchMode(ChatInputMode.InputDefault, false);
			}
		}
		public void OnPageBack()
		{
			if (this.LayoutRoot.get_Visibility() == 1)
			{
				this.LayoutRoot.set_Visibility(0);
			}
			this.mVoiceService.IsFowardToOtherPage = false;
			this.setBackground();
		}
		public void OnPageForward(Uri targetPage)
		{
			this.mVoiceService.IsFowardToOtherPage = true;
			ScreenLockService.Resume();
		}
		public bool OnBackKeyPress(CancelEventArgs cancelEventArgs_0)
		{
			Log.smethod_5("ChatPage", "OnBackKeyPress");
			if (this.IsEmojiListCtrlExist && this.mEmojiListCtrl.get_Visibility() == null)
			{
				cancelEventArgs_0.set_Cancel(true);
				base.get_Dispatcher().BeginInvoke(delegate
				{
					this.SwitchMode(ChatInputMode.InputSmileyMode, false);
					this.mEmojiListCtrl.set_Visibility(1);
				});
				return false;
			}
			if (this.IsImageConfirmControlVisible())
			{
				this.mImageConfirmControl.set_Visibility(1);
				this.mImageConfirmControl.ClearData();
				return false;
			}
			if (this.mCuInputMode != ChatInputMode.InputVoiceMode && this.mCuInputMode != ChatInputMode.InputDefault)
			{
				return false;
			}
			if (this.mExtralChatButton.IsShowing())
			{
				this.mExtralChatButton.Hide();
				return false;
			}
			return true;
		}
		private void ChatList_LoadedComplete(object sender, RoutedEventArgs e)
		{
		}
		private void ChatList_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
		{
			this.SwitchMode(ChatInputMode.InputDefault, false);
			this.hideMsgTips(true);
		}
		public void SendShareCard(Contact contact_0)
		{
			if (contact_0 == null)
			{
				return;
			}
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			string contactCardContent = ServiceCenter.sceneSendMsg.getContactCardContent(contact_0);
			ChatMsg chatMsgInfo = ServiceCenter.sceneSendMsg.buildChatMsg(this.cuUser, contactCardContent, 42);
			ServiceCenter.sceneSendMsg.doSendMsg(chatMsgInfo, 1);
		}
		public int GetPicProgress(int msgLocalId)
		{
			if (ChatPageCtrl.ProgressDic == null)
			{
				return -1;
			}
			if (!ChatPageCtrl.ProgressDic.ContainsKey(msgLocalId))
			{
				return 0;
			}
			return ChatPageCtrl.ProgressDic.get_Item(msgLocalId);
		}
		private void SetPicProgress(int msgLocalId, int int_0)
		{
			if (ChatPageCtrl.ProgressDic == null)
			{
				return;
			}
			if (int_0 == 100)
			{
				ChatPageCtrl.ProgressDic.Remove(msgLocalId);
				return;
			}
			ChatPageCtrl.ProgressDic.set_Item(msgLocalId, int_0);
		}
		private void SendPicInit()
		{
			if (ChatPageCtrl.ProgressDic == null)
			{
				ChatPageCtrl.ProgressDic = new Dictionary<int, int>();
			}
			this.mPicSendingWatcher = new EventWatcher(this, this, new EventHandlerDelegate(this.onPicSendingEventHandler));
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_SENDIMG_PROGRESS, this.mPicSendingWatcher);
			this.mPicSendCompleteWatcher = new EventWatcher(this, this, new EventHandlerDelegate(this.onPicSendCompleteEventHandler));
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_SENDIMG_COMPLETE, this.mPicSendCompleteWatcher);
		}
		private void SendPicUnit()
		{
			EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_SENDIMG_PROGRESS, this.mPicSendingWatcher);
			EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_SENDIMG_COMPLETE, this.mPicSendCompleteWatcher);
		}
		private void onPicSendingEventHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs == null)
			{
				return;
			}
			ParamReturn paramReturn = evtArgs.mObject as ParamReturn;
			if (paramReturn == null)
			{
				return;
			}
			if (paramReturn.mToTalker != this.cuUser)
			{
				return;
			}
			this.UpdateImageProgressByLocalId(paramReturn.mImageLocalId, paramReturn.mProgress);
		}
		private void onPicSendCompleteEventHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs == null)
			{
				return;
			}
			ParamReturn paramReturn = evtArgs.mObject as ParamReturn;
			if (paramReturn == null)
			{
				return;
			}
			if (paramReturn.mToTalker != this.cuUser)
			{
				return;
			}
			this.UpdateImageProgressByLocalId(paramReturn.mImageLocalId, 100);
		}
		private void UpdateImageProgressByLocalId(int localId, int progress)
		{
			if (this.mDataList == null)
			{
				return;
			}
			for (int i = 0; i < this.mDataList.get_Count(); i++)
			{
				ChatMsg chatMsg = this.mDataList[i];
				if (chatMsg.nMsgLocalID == localId)
				{
					this.SetPicProgress(chatMsg.nMsgLocalID, progress);
					this.mDataList[i] = this.mDataList[i];
					return;
				}
			}
		}
		private void AutoSendImg(string strPicToken)
		{
			Log.smethod_5("ChatPage", "AutoSendImg " + strPicToken);
			if (!(strPicToken.Substring(0, 4).ToLower() == "http") && !(strPicToken.Substring(0, 7).ToLower() == "storage"))
			{
				try
				{
					MediaLibrary mediaLibrary = new MediaLibrary();
					Picture pictureFromToken = mediaLibrary.GetPictureFromToken(strPicToken);
					this.ImageConfirmOk(pictureFromToken.GetImage(), true);
					return;
				}
				catch (Exception ex)
				{
					Log.smethod_1("ChatPage", ex.ToString());
					return;
				}
			}
			byte[] array = SnsMediaStorage.load(strPicToken);
			if (array != null && array.Length > 0)
			{
				Stream imgStream = new MemoryStream(array);
				this.ImageConfirmOk(imgStream, true);
				return;
			}
		}
		private void ChooserPicture()
		{
			ToolFunction.GotoPageForUserControl("/Source/UI/ImageFilter/ImageFilterPage.xaml", new object[]
			{
				new ImageFilterConfig(new ImageFilterCallBack(this.PhotoChooserTaskCompleted), ImageFilterGetPicMode.GetPicMode_Choose_With_Take, 0, 0, null)
				{
					GetPicMode = ImageFilterGetPicMode.GetPicMode_Choose_Exist,
					RawImageHandleCallBack = new RawImageHandleCallBack(this.PhotoChooserTaskRawImageCompleted)
				}
			}, false);
		}
		private void TakePhoto()
		{
			ToolFunction.GotoPageForUserControl("/Source/UI/ImageFilter/ImageFilterPage.xaml", new object[]
			{
				new ImageFilterConfig(new ImageFilterCallBack(this.photoCameraCapture_Completed), ImageFilterGetPicMode.GetPicMode_Choose_With_Take, 0, 0, null)
				{
					GetPicMode = ImageFilterGetPicMode.GetPicMode_Take_Photo,
					isSaveToAlbum = ImageFilterMgr.IsSettingAutoSavePhotos(),
					RawImageHandleCallBack = new RawImageHandleCallBack(this.photoCameraCaptureRawImage_Completed)
				}
			}, false);
		}
		private void photoCameraCapture_Completed(Stream resultData)
		{
			if (resultData != null)
			{
				Log.smethod_5("ChatPage", "photoCameraCapture_Completed");
				this.ImageConfirmOk(resultData, true);
			}
		}
		private void photoCameraCaptureRawImage_Completed(Stream resultData)
		{
			if (resultData != null)
			{
				Log.smethod_5("ChatPage", "photoCameraCaptureRawImage_Completed");
				this.ImageConfirmOk(resultData, false);
			}
		}
		private void ImageIconButton_Click(object sender, EventArgs e)
		{
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			this.ChatList.Focus();
			if (this.mCuInputMode == ChatInputMode.InputSmileyMode)
			{
				this.SwitchMode(ChatInputMode.InputDefault, false);
			}
			this.mmmessageBox_0 = MMMessageBox.Show(strings.ChatSendPicDlgTitle, strings.ChatSendPicDlgInfo, true, strings.ChatSendPicDlgTakePhoto, strings.ChatSendPicDlgImgLib);
			this.mmmessageBox_0.ReturnEvent = new DlgReturnEvent(this.SelectPicDlgReturn);
		}
		public void SelectPicDlgReturn(DlgReturnEventArg dlgReturnEventArg_0)
		{
			this.mmmessageBox_0 = null;
			switch (MMMessageBox.GetUserClickResult(dlgReturnEventArg_0))
			{
			case 0:
				this.TakePhoto();
				return;
			case 1:
				this.ChooserPicture();
				return;
			default:
				return;
			}
		}
		private void CheckImageConfirmControl()
		{
			if (this.mImageConfirmControl == null)
			{
				this.mImageConfirmControl = new ImageConfirmControl();
				this.RootGrid.get_Children().Add(this.mImageConfirmControl);
			}
		}
		private bool IsImageConfirmControlVisible()
		{
			return this.mImageConfirmControl != null && this.mImageConfirmControl.get_Visibility() == null;
		}
		private void PhotoChooserTaskCompleted(Stream resultData)
		{
			if (resultData != null)
			{
				Log.smethod_5("ChatPage", "PhotoChooserTaskCompleted");
				this.ImageConfirmOk(resultData, true);
			}
		}
		private void PhotoChooserTaskRawImageCompleted(Stream resultData)
		{
			if (resultData != null)
			{
				Log.smethod_5("ChatPage", "PhotoChooserTaskRawImageCompleted");
				this.ImageConfirmOk(resultData, false);
			}
		}
		public void ImageConfirmOk(Stream imgStream, bool isNeedScale = true)
		{
			imgStream.set_Position(0L);
			byte[] array = new byte[100];
			imgStream.Read(array, 0, 100);
			ImageFromat imageFormat = ImageUtil.getImageFormat(array);
			imgStream.set_Position(0L);
			Log.smethod_5("ChatPage", "image format = " + imageFormat.ToString());
			if (imageFormat != ImageFromat.jpeg)
			{
				if (imageFormat != ImageFromat.const_2)
				{
					Log.smethod_1("ChatPage", "send gif image is not supported");
					MMMessageBox.Show(strings.ChatImgSendFormatError, true, "确定");
					return;
				}
			}
			if (this.cuUser.EndsWith("@qqim"))
			{
				ChatMsg chatMsg = ServiceCenter.sceneSendImg.doScene(this.cuUser, this.GetFileName(null), imgStream, 39, new ParamEx
				{
					thumbPath = null,
					isNeedScale = isNeedScale
				});
				if (chatMsg != null)
				{
					this.UpdateImageProgressByLocalId(chatMsg.nMsgLocalID, 0);
					return;
				}
			}
			else
			{
				ChatMsg chatMsg2 = ServiceCenter.sceneSendImg.doScene(this.cuUser, this.GetFileName(null), imgStream, 3, new ParamEx
				{
					thumbPath = null,
					isNeedScale = isNeedScale
				});
				if (chatMsg2 != null)
				{
					this.UpdateImageProgressByLocalId(chatMsg2.nMsgLocalID, 0);
					return;
				}
			}
		}
		public void SendGif(Stream gifStream, CustomSmiley customSmiley)
		{
			if (this.cuUser.EndsWith("@qqim"))
			{
				MMMessageBox.Show(strings.MessageContent_SendMessage_NotSupport, true, "确定");
				return;
			}
			CustomSmileyManager.SendGif(this.cuUser, gifStream, customSmiley);
		}
		public void SendGame(int gameType)
		{
			if (this.cuUser.EndsWith("@qqim"))
			{
				MMMessageBox.Show(strings.MessageContent_SendMessage_NotSupport, true, "确定");
				return;
			}
			CustomSmileyManager.SendGame(this.cuUser, gameType);
		}
		private string GetFileName(PhotoResult photoResult_0 = null)
		{
			return Guid.NewGuid().ToString();
		}
		public static bool IsRecordingOrPlayingVoice()
		{
			ChatPageCtrl chatPageCtrl = ChatContainerPage.tryGetCuChatPage();
			return chatPageCtrl != null && chatPageCtrl.mVoiceService != null && (chatPageCtrl.mVoiceService.IsRecording || chatPageCtrl.mVoiceService.IsPlaying);
		}
		public static void ReadyToRecord()
		{
			ChatPageCtrl chatPageCtrl = ChatContainerPage.tryGetCuChatPage();
			if (chatPageCtrl == null)
			{
				return;
			}
			chatPageCtrl.mVoiceService.Clear();
			chatPageCtrl.ClearMediaPlayer();
		}
		private void PlayVoiceInit()
		{
			this.mVoiceService = new VoiceService(this.MMAudioPlayer);
		}
		private void PlayVoiceUnit()
		{
		}
		public ChatVoiceItem getVoiceItemAt(int index)
		{
			if (index < 0 || index >= this.ChatList.get_Items().get_Count())
			{
				return null;
			}
			ChatListItem itemAt = this.ChatList.getItemAt<ChatListItem>(index);
			if (itemAt == null)
			{
				return null;
			}
			return itemAt.getRealItem<ChatVoiceItem>();
		}
		public void VoiceItemClick(string string_0, ChatMsg chatMsg_0, ChatVoiceItem chatVoiceItem)
		{
			if (string.IsNullOrEmpty(string_0))
			{
				return;
			}
			if (chatMsg_0 == null)
			{
				return;
			}
			if (chatVoiceItem == null)
			{
				return;
			}
			if (chatMsg_0.GetStatus() != MsgUIStatus.Success)
			{
				return;
			}
			int num = -1;
			int i = 0;
			while (i < this.mDataList.get_Count())
			{
				if (this.mDataList[i].nMsgLocalID == chatMsg_0.nMsgLocalID)
				{
					num = i;
					IL_58:
					if (num < 0)
					{
						return;
					}
					if (ChatMsgMgr.getVoiceStatus(chatMsg_0) == MsgReadStatus.MsgUnRead)
					{
						this.mVoiceService.Clear();
						this.ClearMediaPlayer();
						for (int j = num; j < this.mDataList.get_Count(); j++)
						{
							ChatMsg chatMsg_ = this.mDataList[j];
							if (ChatMsgMgr.getVoiceStatus(chatMsg_) == MsgReadStatus.MsgUnRead && chatMsg_0.GetStatus() == MsgUIStatus.Success)
							{
								ChatVoiceItem voiceItemAt = this.getVoiceItemAt(j);
								if (voiceItemAt != null)
								{
									string voiceUrl = ChatMsgMgr.GetVoiceUrl(chatMsg_);
									if (voiceUrl != null)
									{
										this.mVoiceService.PushVoice(voiceUrl, chatMsg_, voiceItemAt);
									}
								}
							}
						}
						return;
					}
					ChatVoiceItem voiceItemAt2 = this.getVoiceItemAt(num);
					if (voiceItemAt2 == null)
					{
						return;
					}
					this.ClearMediaPlayer();
					this.mVoiceService.ClickVoice(string_0, chatMsg_0, voiceItemAt2);
					return;
				}
				else
				{
					i++;
				}
			}
			goto IL_58;
		}
		public void MusicItemClick(ChatMsg chatMsg_0, ChatAppMsgMusicItem chatAppMsgMusicItem)
		{
			if (chatMsg_0 == null)
			{
				return;
			}
			if (chatAppMsgMusicItem == null)
			{
				return;
			}
			this.mVoiceService.Clear();
			this.MMMediaPlayerInit();
			if (this.isMusicPlaying())
			{
				this.ClearMediaPlayer();
				if (this.mChatAppMsgMusicItem != null)
				{
					this.mChatAppMsgMusicItem.refreshImgButton(false);
				}
				if (this.mChatAppMsgMusicItem == chatAppMsgMusicItem)
				{
					ScreenLockService.Resume();
					return;
				}
			}
			ScreenLockService.checkMusicPlaying = new IsMediaPlaying(this.isMusicPlaying);
			ScreenLockService.Awake();
			string text = "";
			AppMusicInfo musicInfo = AppMsgMgr.getMusicInfo(chatMsg_0);
			if (musicInfo != null)
			{
				text = (NetworkDeviceWatcher.isCurrentWifi() ? musicInfo.song_WifiURL : musicInfo.song_WapLiveURL);
			}
			if (!string.IsNullOrEmpty(text))
			{
				this.MMMediaPlayer.set_Source(new Uri(text, 1));
				this.MMMediaPlayer.add_MediaFailed(new EventHandler<ExceptionRoutedEventArgs>(this.MMMediaPlayer_MediaFailed));
				this.MMMediaPlayer.add_CurrentStateChanged(new RoutedEventHandler(this.MMMediaPlayer_CurrentStateChanged));
				this.mChatAppMsgMusicItem = chatAppMsgMusicItem;
				this.mChatAppMsgMusicItem.refreshImgButton(true);
				this.MMMediaPlayer.Play();
			}
			else
			{
				MessageBoxManager.ShowToast(strings.ChatVoiceOpenFail, 2500, null, false);
				Log.smethod_1("ChatPage", "invalid url, url = " + text);
			}
			ServiceCenter.statReportMgr.addStatItem(enKVStatKey.MM_EMBEDMUSICPLAYCOUNT, "0,1");
		}
		private void MMMediaPlayerInit()
		{
			if (this.isMMMediaPlayerInit)
			{
				return;
			}
			string text = "http://qzone-music.qq.com/fcg-bin/fcg_set_musiccookie.fcg?fromtag=34";
			this.MMMediaPlayer.set_Source(new Uri(text, 1));
			this.MMMediaPlayer.Play();
			this.isMMMediaPlayerInit = true;
		}
		private void MMMediaPlayer_CurrentStateChanged(object sender, RoutedEventArgs e)
		{
			if (this.MMMediaPlayer.get_CurrentState() != 1 && this.MMMediaPlayer.get_CurrentState() != 2)
			{
				if (this.MMMediaPlayer.get_CurrentState() != 3)
				{
					this.mChatAppMsgMusicItem.refreshImgButton(false);
					return;
				}
			}
			this.mChatAppMsgMusicItem.refreshImgButton(true);
		}
		public bool isMusicPlaying()
		{
			if (this.MMMediaPlayer == null)
			{
				return false;
			}
			if (this.MMMediaPlayer.get_CurrentState() != 1 && this.MMMediaPlayer.get_CurrentState() != 2)
			{
				if (this.MMMediaPlayer.get_CurrentState() != 3)
				{
					return false;
				}
			}
			return true;
		}
		public void ClearMediaPlayer()
		{
			this.MMMediaPlayer.set_Tag(null);
			this.MMMediaPlayer.Stop();
			this.MMMediaPlayer.ClearValue(MediaElement.SourceProperty);
			ScreenLockService.checkMusicPlaying = null;
		}
		public void MMMediaPlayer_MediaFailed(object sender, EventArgs e)
		{
			if (this.mChatAppMsgMusicItem != null)
			{
				this.mChatAppMsgMusicItem.refreshImgButton(false);
			}
			Log.smethod_5("ChatPage", e.ToString());
			this.ClearMediaPlayer();
			MessageBoxManager.ShowToast(strings.ChatMusicOpenFail, 2500, null, false);
		}
		public void ReceivedVoice(ChatMsg chatMsg_0, ChatVoiceItem chatVoiceItem)
		{
			if (chatMsg_0 == null)
			{
				return;
			}
			if (chatVoiceItem == null)
			{
				return;
			}
			if (chatMsg_0.GetStatus() != MsgUIStatus.Success)
			{
				return;
			}
			if (ChatMsgMgr.GetVoiceUrl(chatMsg_0) == null)
			{
				return;
			}
			Log.smethod_5("ChatPage", "ReceivedVoice:" + chatMsg_0.nMsgLocalID);
		}
		public void SwitchMode(ChatInputMode mode, bool bNotFoucsTxt = false)
		{
			this.mExtralChatButton.Hide();
			if (this.mCuInputMode == mode)
			{
				return;
			}
			this.mCuInputMode = mode;
			if (this.mCuInputMode != this.mInputer.GetMode())
			{
				this.mInputer.SwitchMode(mode, bNotFoucsTxt);
			}
			switch (mode)
			{
			case ChatInputMode.InputTxtMode:
				if (this.mChatEggsCtrl != null)
				{
					this.mChatEggsCtrl.set_Margin(new Thickness(0.0, 400.0, 0.0, 0.0));
				}
				this.ScrollToLast();
				break;
			case ChatInputMode.InputVoiceMode:
				if (this.mChatEggsCtrl != null)
				{
					this.mChatEggsCtrl.set_Margin(new Thickness(0.0, 0.0, 0.0, 0.0));
				}
				break;
			case ChatInputMode.InputSmileyMode:
				this.ScrollToLast();
				break;
			case ChatInputMode.InputDefault:
				if (this.mChatEggsCtrl != null)
				{
					this.mChatEggsCtrl.set_Margin(new Thickness(0.0, 0.0, 0.0, 0.0));
				}
				this.ScrollToLast();
				break;
			default:
				if (this.mChatEggsCtrl != null)
				{
					this.mChatEggsCtrl.set_Margin(new Thickness(0.0, 0.0, 0.0, 0.0));
				}
				this.ScrollToLast();
				break;
			}
			this.RefreshChatListLayoutForSip();
		}
		private void RefreshChatListLayoutForSip()
		{
			if (ContactMgr.IsFmessageUser(this.cuUser))
			{
				return;
			}
			double num;
			if (this.mInputer.IsPagePopUped())
			{
				num = 296.0;
			}
			else
			{
				num = 604.0;
			}
			if (num < 0.0)
			{
				num = 0.0;
			}
			this.ChatList.set_Height(num);
			this.ChatPanelRoot.UpdateLayout();
		}
		private bool IsSipOpen()
		{
			return this.mSipHeight > 0.001;
		}
		public void RootFrameChange(double double_0)
		{
			this.mSipHeight = double_0;
			this.RefreshChatListLayoutForSip();
		}
		private void ChatRoomChangeInit()
		{
			if (this.isInitChatRoomChange)
			{
				return;
			}
			this.isInitChatRoomChange = true;
			this.mChatRoomChangeWatcher = new EventWatcher(this, null, new EventHandlerDelegate(this.onChatRoomChange));
			EventCenter.registerEventWatcher(EventConst.ON_STORAGE_CONTACT_MODIFY, this.mChatRoomChangeWatcher);
		}
		private void ChatRoomChangeUnit()
		{
			if (!this.isInitChatRoomChange)
			{
				return;
			}
			this.isInitChatRoomChange = false;
			EventCenter.removeEventWatcher(EventConst.ON_STORAGE_CONTACT_MODIFY, this.mChatRoomChangeWatcher);
		}
		private void onChatRoomChange(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			List<Contact> listObject = evtArgs.getListObject<Contact>();
			if (listObject == null)
			{
				return;
			}
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			for (int i = 0; i < listObject.get_Count(); i++)
			{
				if (listObject.get_Item(i).strUsrName == this.cuUser)
				{
					this.RefreshMember();
					return;
				}
			}
		}
		private void RefreshMember()
		{
			this.PeopleListBtn.set_IsEnabled(true);
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			if (ContactMgr.getUserType(this.cuUser) == ContactMgr.UserType.UserTypeQQ)
			{
				this.QQPageTitle.Text = this.qqShowName;
				this.PeopleListBtn.ImgSource = new BitmapImage(new Uri(R.theme.plugin_qqoffline_chatmain_people, 0));
			}
			if (ContactMgr.getUserType(this.cuUser) == ContactMgr.UserType.UserTypeChatRoom)
			{
				int num = 0;
				this.PageTitle.Text = ContactHelper.getChatRoomStringInChat(this.cuUser, ref num);
				this.ChatNumTitle.set_Text("(" + num + ")");
				this.PageTitle.set_MaxWidth(401.0 - this.ChatNumTitle.get_ActualWidth() - 16.0);
				this.ChatNumTitle.set_Visibility(0);
				List<string> membersByChatRoomName = ChatRoomMgr.getMembersByChatRoomName(this.cuUser);
				if (membersByChatRoomName != null && membersByChatRoomName.get_Count() != 0 && membersByChatRoomName.Contains(AccountMgr.curUserName))
				{
					this.PeopleListBtn.ImgSource = new BitmapImage(new Uri("/Resource/Img/Chat/peoplelist.png", 0));
				}
				else
				{
					this.PeopleListBtn.ImgSource = new BitmapImage(new Uri("/Resource/Img/Chat/GroupChatRemovedBig.png", 0));
				}
				this.mInputer.inputTxt.bEnableAtNotify = true;
			}
			else
			{
				this.PageTitle.Text = ContactHelper.getDisplayName(this.cuUser, null);
				this.PeopleListBtn.ImgSource = new BitmapImage(new Uri(R.theme.plugin_qqoffline_chatmain_people, 0));
				this.mInputer.inputTxt.bEnableAtNotify = false;
			}
			if (ContactMgr.getUserType(this.cuUser) == ContactMgr.UserType.UserTypePlugin)
			{
				this.PageTitle.set_MaxWidth(480.0);
				this.PeopleListBtn.set_Visibility(1);
			}
		}
		public bool IsAlertMsgNeedShow(ChatMsg chatMsg_0)
		{
			return chatMsg_0 != null && !(chatMsg_0.strTalker == this.cuUser);
		}
		public void ValidToFriend()
		{
			Dialog2BtnWithInputBox.Show(strings.ChatTalkNeedValidTitle, strings.ChatNeedValidInfo, strings.COM_Confirm, strings.COM_Cancel, "", new Dialog2BtnWithInputBox.dismissWithClickBtn(this.SayHiDialogHandler), null, null);
		}
		private void SayHiDialogHandler(object sender, int nClickIndex)
		{
			if (nClickIndex == 0 && sender != null && sender is Dialog2BtnWithInputBox)
			{
				Dialog2BtnWithInputBox dialog2BtnWithInputBox = sender as Dialog2BtnWithInputBox;
				string text = dialog2BtnWithInputBox.txtIn.get_Text();
				if (text == null || text.get_Length() == 0)
				{
					text = strings.ChatDefaultHello;
				}
				if (this.mWatcherSceneAddContactEvent == null)
				{
					this.mWatcherSceneAddContactEvent = new EventWatcher(this, null, new EventHandlerDelegate(this.onSceneEventAddContactHandler));
					EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_VERIFYUSER_SUCCESS, this.mWatcherSceneAddContactEvent);
					EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_VERIFYUSER_ERR, this.mWatcherSceneAddContactEvent);
				}
				ProcessingCover.getProgressBar(this.LayoutRoot, strings.ChatValidSending, null, false, false, null);
				ServiceCenter.sceneVerifyUser.doSceneSendRequestForAddContact(this.cuUser, text, AddContactScene.MM_ADDSCENE_PF_CONTACT);
			}
		}
		private void onSceneEventAddContactHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (this.mWatcherSceneAddContactEvent != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_VERIFYUSER_SUCCESS, this.mWatcherSceneAddContactEvent);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_VERIFYUSER_ERR, this.mWatcherSceneAddContactEvent);
				this.mWatcherSceneAddContactEvent = null;
			}
			if (!evtArgs.checkType<AddContactEventArgs>())
			{
				return;
			}
			AddContactEventArgs addContactEventArgs = (AddContactEventArgs)evtArgs.mObject;
			if (addContactEventArgs == null)
			{
				return;
			}
			if (EventConst.ON_NETSCENE_VERIFYUSER_ERR == evtArgs.mEventID)
			{
				if (evtArgs.mObject != null)
				{
					if (RetConst.MM_ERR_CLIENT == addContactEventArgs.result)
					{
						Log.smethod_5("ChatPage", "ON_LBS_SAYHI_ERROR:" + addContactEventArgs.result);
						MMMessageBox.Show(strings.ChatCreateNetError, true, "确定");
					}
					else
					{
						if (RetConst.MM_ERR_SPAM == addContactEventArgs.result)
						{
							Log.smethod_5("ChatPage", "ON_LBS_SAYHI_ERROR:" + addContactEventArgs.result);
							MMMessageBox.Show(strings.ChatValidContentError, true, "确定");
						}
						else
						{
							if (RetConst.MM_ERR_FREQ_LIMITED == addContactEventArgs.result)
							{
								MMMessageBox.Show(strings.ChatValidTooMuch, true, "确定");
							}
							else
							{
								Log.smethod_5("ChatPage", "ON_LBS_SAYHI_ERROR:" + addContactEventArgs.result);
								MMMessageBox.Show(strings.ChatValidError, true, "确定");
							}
						}
					}
				}
			}
			else
			{
				if (EventConst.ON_NETSCENE_VERIFYUSER_SUCCESS == evtArgs.mEventID)
				{
					MessageBoxManager.ShowToast(strings.ChatValidSuccess, 2500, null, false);
				}
			}
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
		}
		private void PeopleListBtn_Click(object sender, RoutedEventArgs e)
		{
			if (this.containerPage == null)
			{
				return;
			}
			if (this.cuUser.Contains("@bottle"))
			{
				BotterDetailInfo.GotoThisPage(this.cuUser, false);
				return;
			}
			if (ContactHelper.IsVerifiedContact(this.cuUser))
			{
				ContactDetailViewForAll.GotoContactDitailView(this.cuUser, ContactDetailFromType.FROM_MMCONTACT, false);
				return;
			}
			object[] object_ = new object[]
			{
				this.cuUser
			};
			if (ContactMgr.getUserType(this.cuUser) == ContactMgr.UserType.UserTypeChatRoom)
			{
				List<string> membersByChatRoomName = ChatRoomMgr.getMembersByChatRoomName(this.cuUser);
				if (membersByChatRoomName == null || membersByChatRoomName.get_Count() == 0)
				{
					NetSceneBatchGetContact arg_92_0 = ServiceCenter.sceneBatchGetContact;
					List<string> list = new List<string>();
					list.Add(this.cuUser);
					arg_92_0.doScene(list);
				}
				if (membersByChatRoomName == null || !membersByChatRoomName.Contains(AccountMgr.curUserName))
				{
					return;
				}
			}
			ToolFunction.GotoPageForUserControl("/Source/UI/Chat/PeopleListPage.xaml", object_, false);
		}
		private void StatusSaveInit()
		{
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			int num = 0;
			string text = "";
			ConversationMgr.GetChatStatus(this.cuUser, ref num, ref text);
			this.mInputer.inputTxt.Text = text;
			if (num == 0)
			{
				this.SwitchMode(ChatInputMode.InputVoiceMode, false);
			}
			else
			{
				this.SwitchMode(ChatInputMode.InputTxtMode, true);
				this.SwitchMode(ChatInputMode.InputDefault, false);
			}
			this.oldTxt = text;
			this.oldchatstatus = num;
		}
		private void StatusSaveUnit()
		{
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return;
			}
			if (this.mInputer.inputTxt.realBox == null)
			{
				return;
			}
			int chatstatus = 0;
			string string_0 = "";
			if (this.mCuInputMode == ChatInputMode.InputVoiceMode)
			{
				chatstatus = 0;
			}
			else
			{
				chatstatus = 1;
			}
			if (!string.IsNullOrEmpty(this.mInputer.inputTxt.realBox.get_Text()))
			{
				string_0 = this.mInputer.inputTxt.realBox.get_Text();
			}
			string username = this.cuUser;
			if (string_0 == this.oldTxt && chatstatus == this.oldchatstatus)
			{
				return;
			}
			UIDelayService.getInstance().Push(delegate
			{
				Log.smethod_5("ChatPage", "SaveChatStatus");
				ConversationMgr.SaveChatStatus(username, chatstatus, string_0);
			});
		}
		private void PeopleDetailBtn_Click(object sender, RoutedEventArgs e)
		{
			if (this.containerPage == null)
			{
				return;
			}
			object[] object_ = new object[]
			{
				this.cuUser
			};
			this.containerPage.GetRealPage().GoToPage("/Source/Plugin/QQOfflineMsg/UI/QQFriendInfoView.xaml", object_, false);
		}
		private void InitQQChatTitle(string titleName)
		{
			this.ChatTitle.set_Visibility(1);
			this.QQChatTitle.set_Visibility(0);
			this.QQPageTitle.Text = titleName;
		}
		private void NeedQQPwdInit()
		{
			this.mQQPwdWatcher = new EventWatcher(this, this, new EventHandlerDelegate(this.onNeedQQPwdEventHandler));
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_SENDMSG_FAIL, this.mQQPwdWatcher);
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_UPLOADVOICE_ERR, this.mQQPwdWatcher);
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_SENDIMG_FAIL, this.mQQPwdWatcher);
		}
		private void NeedQQPwdUnit()
		{
			if (this.mQQPwdWatcher != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_SENDMSG_FAIL, this.mQQPwdWatcher);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_UPLOADVOICE_ERR, this.mQQPwdWatcher);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_SENDIMG_FAIL, this.mQQPwdWatcher);
				this.mQQPwdWatcher = null;
			}
			if (this.mQQPwdVerifyWatcher != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_BINDQQ_SUCCESS, this.mWatcherSceneAddContactEvent);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_BINDQQ_ERR, this.mWatcherSceneAddContactEvent);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_BINDQQ_NEEDVERIFY, this.mWatcherSceneAddContactEvent);
				this.mQQPwdVerifyWatcher = null;
			}
		}
		private void onNeedQQPwdEventHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs == null)
			{
				return;
			}
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_SENDMSG_FAIL)
			{
				MsgResultRet msgResultRet = evtArgs.mObject as MsgResultRet;
				if (msgResultRet == null)
				{
					return;
				}
				this.tmpChatmsg = msgResultRet.msgChat;
				this.trasnID = -1;
				RetConst retCode = msgResultRet.retCode;
				if (retCode == RetConst.MM_ERR_NEED_QQPWD)
				{
					Dialog2BtnWithPwdBox.Show(strings.BindQQ_InputQQPWD, strings.Plugin_QQOffline_AlertQQPwdContent, strings.COM_Confirm, strings.COM_Cancel, "", new Dialog2BtnWithPwdBox.dismissWithClickBtn(this.InputQQPwdDialogHandler), null, null);
					return;
				}
			}
			else
			{
				if (evtArgs.mEventID == EventConst.ON_NETSCENE_UPLOADVOICE_ERR)
				{
					UploadVoiceEventArgs uploadVoiceEventArgs = evtArgs.mObject as UploadVoiceEventArgs;
					if (uploadVoiceEventArgs == null)
					{
						return;
					}
					this.tmpChatmsg = uploadVoiceEventArgs.chatMsg;
					this.trasnID = -1;
					RetConst retCode2 = uploadVoiceEventArgs.retCode;
					if (retCode2 == RetConst.MM_ERR_NEED_QQPWD)
					{
						Dialog2BtnWithPwdBox.Show(strings.BindQQ_InputQQPWD, strings.Plugin_QQOffline_AlertQQPwdContent, strings.COM_Confirm, strings.COM_Cancel, "", new Dialog2BtnWithPwdBox.dismissWithClickBtn(this.InputQQPwdDialogHandler), null, null);
						return;
					}
				}
				else
				{
					if (evtArgs.mEventID == EventConst.ON_NETSCENE_SENDIMG_FAIL)
					{
						ParamReturn paramReturn = evtArgs.mObject as ParamReturn;
						if (paramReturn == null)
						{
							return;
						}
						this.tmpChatmsg = new ChatMsg();
						this.tmpChatmsg.strTalker = this.cuUser;
						this.tmpChatmsg.nIsSender = 1;
						this.tmpChatmsg.nMsgType = 39;
						this.trasnID = paramReturn.mImgMsgTranID;
						RetConst mRetCode = paramReturn.mRetCode;
						if (mRetCode == RetConst.MM_ERR_NEED_QQPWD)
						{
							Dialog2BtnWithPwdBox.Show(strings.BindQQ_InputQQPWD, strings.Plugin_QQOffline_AlertQQPwdContent, strings.COM_Confirm, strings.COM_Cancel, "", new Dialog2BtnWithPwdBox.dismissWithClickBtn(this.InputQQPwdDialogHandler), null, null);
						}
					}
				}
			}
		}
		private void InputQQPwdDialogHandler(object sender, int nClickIndex)
		{
			if (nClickIndex == 0 && sender != null && sender is Dialog2BtnWithPwdBox)
			{
				Dialog2BtnWithPwdBox dialog2BtnWithPwdBox = sender as Dialog2BtnWithPwdBox;
				string password = dialog2BtnWithPwdBox.textBoxPassword.Password;
				if (this.mQQPwdVerifyWatcher == null)
				{
					this.mQQPwdVerifyWatcher = new EventWatcher(this, null, new EventHandlerDelegate(this.onSceneEventQQPwdVerifyHandler));
					EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_BINDQQ_SUCCESS, this.mQQPwdVerifyWatcher);
					EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_BINDQQ_NEEDVERIFY, this.mQQPwdVerifyWatcher);
					EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_BINDQQ_ERR, this.mQQPwdVerifyWatcher);
				}
				ProcessingCover.getProgressBar(this.LayoutRoot, strings.ChatValidSending, null, false, false, null);
				ServiceCenter.sceneBindQQ.doSceneVerifyQQPwd(password);
			}
		}
		private void InputQQVcodeDialogHandler(object sender, int nClickIndex)
		{
			if (nClickIndex == 0 && sender != null && sender is QQMsgVerifyControl)
			{
				QQMsgVerifyControl qQMsgVerifyControl = sender as QQMsgVerifyControl;
				ServiceCenter.sceneBindQQ.doSceneVerifyQQPwdWithVerify(this.imgSid, qQMsgVerifyControl.txtInVcode.get_Text());
				ProcessingCover.getProgressBar(this.LayoutRoot, strings.ChatValidSending, null, false, false, null);
			}
		}
		private void onSceneEventQQPwdVerifyHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			Log.smethod_5("ChatPage", "QQ Msg Verify has returned. evtArgs.mEventID ==" + evtArgs.mEventID);
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_BINDQQ_SUCCESS)
			{
				ChatMsgMgr.resendTalkMsg(this.tmpChatmsg, this.trasnID);
				return;
			}
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_BINDQQ_NEEDVERIFY)
			{
				if (evtArgs == null)
				{
					Log.smethod_5("ChatPage", "QQ Msg Need Verify, ret = null;");
				}
				VerifyCodeArgs verifyCodeArgs = evtArgs.mObject as VerifyCodeArgs;
				this.imgSid = verifyCodeArgs.mImageSid;
				this.imgBuf = verifyCodeArgs.mImageBuf;
				if (QQMsgVerifyControl.Refresh(this.imgSid, this.imgBuf) == null)
				{
					QQMsgVerifyControl qQMsgVerifyControl = QQMsgVerifyControl.Show(false, this.imgSid, this.imgBuf, new QQMsgVerifyControl.dismissWithClickBtn(this.InputQQVcodeDialogHandler));
					return;
				}
			}
			else
			{
				if (evtArgs.mEventID == EventConst.ON_NETSCENE_BINDQQ_ERR)
				{
					Dialog2BtnWithPwdBox.Show(strings.BindQQ_InputQQPWD, strings.Plugin_QQOffline_AlertQQPwdError, strings.COM_Confirm, strings.COM_Cancel, "", new Dialog2BtnWithPwdBox.dismissWithClickBtn(this.InputQQPwdDialogHandler), null, null);
				}
			}
		}
		private void ObscuredInit()
		{
			PhoneApplicationFrame phoneApplicationFrame = Application.get_Current().get_RootVisual() as PhoneApplicationFrame;
			if (phoneApplicationFrame == null)
			{
				return;
			}
			phoneApplicationFrame.add_Obscured(new EventHandler<ObscuredEventArgs>(this.frame_Obscured));
			phoneApplicationFrame.add_Unobscured(new EventHandler(this.frame_Unobscured));
		}
		private void ObscuredUnit()
		{
			PhoneApplicationFrame phoneApplicationFrame = Application.get_Current().get_RootVisual() as PhoneApplicationFrame;
			if (phoneApplicationFrame == null)
			{
				return;
			}
			phoneApplicationFrame.remove_Obscured(new EventHandler<ObscuredEventArgs>(this.frame_Obscured));
			phoneApplicationFrame.remove_Unobscured(new EventHandler(this.frame_Unobscured));
		}
		private void frame_Unobscured(object sender, EventArgs e)
		{
			Log.smethod_5("ChatPage", "frame_Unobscured");
			this.mVoiceService.IsFowardToOtherPage = false;
		}
		private void frame_Obscured(object sender, ObscuredEventArgs e)
		{
			Log.smethod_5("ChatPage", "frame_Obscured");
			this.mVoiceService.IsFowardToOtherPage = true;
		}
		private void SaveToCache()
		{
			if (ChatListItem.mHeadImgLoadService == null)
			{
				return;
			}
			if (ChatListItem.mHeadImgLoadService.mDataList == null)
			{
				return;
			}
			Log.smethod_5("ChatPage", "SaveToCache");
			using (List<BaseHeadImgItem>.Enumerator enumerator = ChatListItem.mHeadImgLoadService.mDataList.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					BaseHeadImgItem current = enumerator.get_Current();
					ChatListItem chatListItem = current as ChatListItem;
					if (chatListItem != null)
					{
						FrameworkElement uIElementToCache = chatListItem.GetUIElementToCache();
						if (uIElementToCache != null)
						{
							ChatContainerPage.mItemCacheService.RestoreItem(uIElementToCache);
						}
					}
				}
			}
		}
		private void registerEvent()
		{
			if (this.mWatchMsgChange == null)
			{
				this.mWatchMsgChange = new EventWatcher(this.mObjectWatcher, null, new EventHandlerDelegate(this.OnMsgChange));
				EventCenter.registerEventWatcher(EventConst.ON_STORAGE_CHAT_MSG_ADD, this.mWatchMsgChange);
				EventCenter.registerEventWatcher(EventConst.ON_STORAGE_CHAT_MSG_MODIFY, this.mWatchMsgChange);
				EventCenter.registerEventWatcher(EventConst.ON_STORAGE_CHAT_MSG_DEL, this.mWatchMsgChange);
			}
			if (this.mWatchBGChange == null)
			{
				this.mWatchBGChange = new EventWatcher(this, null, new EventHandlerDelegate(this.OnBGChange));
				EventCenter.registerEventWatcher(EventConst.ON_CHAT_BACKGROUND_CHANGED, this.mWatchBGChange);
			}
		}
		private void unRegisterEvent()
		{
			if (this.mWatchMsgChange != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_STORAGE_CHAT_MSG_ADD, this.mWatchMsgChange);
				EventCenter.removeEventWatcher(EventConst.ON_STORAGE_CHAT_MSG_MODIFY, this.mWatchMsgChange);
				EventCenter.removeEventWatcher(EventConst.ON_STORAGE_CHAT_MSG_DEL, this.mWatchMsgChange);
				this.mWatchMsgChange = null;
			}
			if (this.mWatchBGChange != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_CHAT_BACKGROUND_CHANGED, this.mWatchBGChange);
				this.mWatchBGChange = null;
			}
		}
		private void OnBGChange(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.setBackground();
		}
		private void OnMsgChange(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs == null)
			{
				return;
			}
			switch (evtArgs.mEventID)
			{
			case EventConst.ON_STORAGE_CHAT_MSG_ADD:
				if (this.cuUser == "fmessage")
				{
					this.gridNoFmessageTip.set_Visibility(1);
					return;
				}
				break;
			case EventConst.ON_STORAGE_CHAT_MSG_DEL:
				if (this.cuUser == "fmessage" && StorageMgr.chatMsg.getMsgNum("fmessage") == 0)
				{
					this.gridNoFmessageTip.set_Visibility(0);
				}
				break;
			case EventConst.ON_STORAGE_CHAT_MSG_MODIFY:
				break;
			default:
				return;
			}
		}
		public void CreatMenu()
		{
			this.menu = new ContextMenu();
			this.menu.set_Width(200.0);
			this.menu.set_Background(R.theme.CONTEXTMENU_BACKGROUND_BRUSH);
			this.menu.IsZoomEnabled = true;
			this.changeBGItem = new MenuItem();
			this.changeBGItem.Header = strings.ChatBackground_Button;
			this.changeBGItem.set_Foreground(R.theme.CONTEXTMENU_FOREGROUND_BRUSH);
			this.changeBGItem.Click += new RoutedEventHandler(this.changeBGItem_Click);
			this.menu.get_Items().Add(this.changeBGItem);
			ContextMenuService.SetContextMenu(this.ChatListLayout, this.menu);
		}
		private void ChatListLayout_Hold(object sender, GestureEventArgs e)
		{
			e.set_Handled(this.bIsChatListLayoutHold);
		}
		private void changeBGItem_Click(object sender, RoutedEventArgs e)
		{
			if (this.cuUser != null && this.cuUser.get_Length() > 0)
			{
				ToolFunction.GotoPageForUserControl("/Source/UI/Chat/background/SetBackgroundPage.xaml", new object[]
				{
					this.cuUser
				}, false);
			}
		}
		public void EmojiSelectComplete(string EmojiStr)
		{
			base.get_Dispatcher().BeginInvoke(delegate
			{
				this.SwitchMode(ChatInputMode.InputSmileyMode, false);
			});
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			if (this.cuUser.EndsWith("@qqim"))
			{
				MMMessageBox.Show(strings.MessageContent_SendMessage_NotSupport, true, "确定");
				return;
			}
			if (string.IsNullOrEmpty(EmojiStr))
			{
				return;
			}
			ChatMsg chatMsg = ServiceCenter.sceneSendMsg.buildChatMsg(this.cuUser, EmojiStr, 1);
			if (chatMsg != null)
			{
				ServiceCenter.sceneSendMsg.doSendMsg(chatMsg, 4);
			}
		}
		private void initInputer()
		{
			if (this.mBIsInputerInited)
			{
				return;
			}
			this.mBIsInputerInited = true;
			this.ExtraActionBtn = new RoundButton();
			this.ExtraActionBtn.Orientation = 1;
			RoundButton arg_45_0 = this.ExtraActionBtn;
			BitmapImage bitmapImage = new BitmapImage();
			bitmapImage.set_UriSource(new Uri("/Resource/Img/Chat/extra/add.png", 2));
			arg_45_0.ImageSource = bitmapImage;
			this.ExtraActionBtn.set_Content("");
			this.ExtraActionBtn.set_Width(60.0);
			this.ExtraActionBtn.set_Height(53.0);
			Control arg_9A_0 = this.ExtraActionBtn;
			SolidColorBrush solidColorBrush = new SolidColorBrush();
			solidColorBrush.set_Color(Colors.get_White());
			arg_9A_0.set_Foreground(solidColorBrush);
			Control arg_B7_0 = this.ExtraActionBtn;
			SolidColorBrush solidColorBrush2 = new SolidColorBrush();
			solidColorBrush2.set_Color(Colors.get_White());
			arg_B7_0.set_BorderBrush(solidColorBrush2);
			this.ExtraActionBtn.set_VerticalAlignment(2);
			this.ExtraActionBtn.set_HorizontalAlignment(1);
			this.ExtraActionBtn.add_ManipulationStarted(new EventHandler<ManipulationStartedEventArgs>(this.ExtraActionBtn_ManipulationStarted));
			this.ExtraActionBtn.add_ManipulationCompleted(new EventHandler<ManipulationCompletedEventArgs>(this.ExtraActionBtn_ManipulationCompleted));
			this.ExtraActionBtn.add_Click(new RoutedEventHandler(this.ExtraActionBtn_Click));
			this.ExtraActionBtn.set_Margin(new Thickness(0.0, 0.0, 5.0, 9.0));
			this.mExtralChatButton.contentStackPanel.set_Margin(new Thickness(0.0, 0.0, 6.0, 0.0));
			this.mExtralChatButton.triangleFlag.set_Margin(new Thickness(0.0, 0.0, 10.0, 12.0));
			this.mInputer.inputBk.get_Children().Insert(3, this.ExtraActionBtn);
			this.mInputer.UpdateLayout();
		}
		private object mInputer_mDlgBtnSendText(object sender, object object_0)
		{
			this.DoSend((string)object_0);
			return null;
		}
		private void DoSend(string strInput)
		{
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			string text = strInput.Trim();
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			List<EggItem> containChatEggs = ChatContainerPage.getContainChatEggs(text);
			if (containChatEggs.get_Count() > 0)
			{
				ChatContainerPage.doChatEggs(containChatEggs, ChatEggsCtrl.EggType.SendEgg);
			}
			if (strInput != null && strInput.get_Length() != 0)
			{
				this.ScrollToLast();
				bool flag = false;
				bool flag2 = false;
				string text2 = EmojiManager.GetInstance().ConvertInputStrToCodeStr(strInput, ref flag);
				text2 = EmojiManager.GetInstance().SbCodeToUtf16Code(text2, ref flag2);
				ChatMsg chatMsg;
				if (this.cuUser.EndsWith("@qqim"))
				{
					chatMsg = ServiceCenter.sceneSendMsg.buildChatMsg(this.cuUser, text2, 36);
				}
				else
				{
					chatMsg = ServiceCenter.sceneSendMsg.buildChatMsg(this.cuUser, text2, 1);
				}
				if (chatMsg != null)
				{
					int emojiType = 1;
					if (flag || flag2)
					{
						emojiType = 2;
					}
					ServiceCenter.sceneSendMsg.doSendMsg(chatMsg, emojiType);
				}
				strInput = "";
				return;
			}
			MessageBoxManager.ShowToast(strings.ChatEmptyTxtHint, 2500, null, false);
		}
		public void AtMemberFromItemHeadImg(string strNick)
		{
			if (ContactMgr.getUserType(this.cuUser) != ContactMgr.UserType.UserTypeChatRoom)
			{
				return;
			}
			if (this.mInputer != null && this.mInputer.inputTxt.realBox != null)
			{
				ChatInputTextBox expr_3C = this.mInputer.inputTxt;
				expr_3C.Text = expr_3C.Text + "@" + strNick + " ";
				this.mInputer.inputTxt.realBox.set_SelectionStart(this.mInputer.inputTxt.Text.get_Length());
				this.mInputer.inputTxt.realBox.set_SelectionLength(0);
				base.get_Dispatcher().BeginInvoke(delegate
				{
					this.mInputer.SwitchMode(ChatInputMode.InputTxtMode, false);
				});
			}
		}
		private void delegateGetContact(Contact mCon)
		{
			if (this.mInputer != null && this.mInputer.inputTxt.realBox != null)
			{
				ChatInputTextBox expr_25 = this.mInputer.inputTxt;
				expr_25.Text = expr_25.Text + mCon.strNickName + " ";
				this.bFromAtMemberDelegate = true;
			}
		}
		private void UpdateTxtByAtMember()
		{
			this.mInputer.inputTxt.realBox.set_SelectionStart(this.mInputer.inputTxt.Text.get_Length());
			this.mInputer.inputTxt.realBox.set_SelectionLength(0);
			this.mInputer.SwitchMode(ChatInputMode.InputTxtMode, false);
			this.bFromAtMemberDelegate = false;
		}
		private void InputTxt_AtMember(object sender, object object_0)
		{
			if (ContactMgr.getUserType(this.cuUser) != ContactMgr.UserType.UserTypeChatRoom)
			{
				return;
			}
			if (this.LayoutRoot.get_Visibility() == null)
			{
				this.LayoutRoot.set_Visibility(1);
			}
			object[] object_ = new object[]
			{
				new DelegateGetContact(this.delegateGetContact),
				ChatRoomMgr.getChatRoomMemberContactList(this.cuUser)
			};
			ToolFunction.GotoPageForUserControl("/Source/UI/Chat/ChatRoom/ChatroomAtMemberList.xaml", object_, false);
		}
		private object mInputer_mDlgInputAtMember(object sender, object object_0)
		{
			this.InputTxt_AtMember(sender, object_0);
			return null;
		}
		private object mInputer_mDlgOnEndPushPage(object sender, object object_0)
		{
			return null;
		}
		private object mInputer_mDlgOnInputerModeChange(object sender, object object_0)
		{
			ChatInputMode mode = (ChatInputMode)object_0;
			this.SwitchMode(mode, false);
			return null;
		}
		private object mInputer_mDlgOnRealBoxGotFocus(object sender, object object_0)
		{
			this.isInputFocus = true;
			return null;
		}
		private object mInputer_mDlgOnRealBoxLostFocus(object sender, object object_0)
		{
			this.isInputFocus = false;
			return null;
		}
		private object mInputer_mDlgOnStartPushPage(object sender, object object_0)
		{
			this.ScrollToLast();
			return null;
		}
		private object mInputer_mDlgVoiceInputStarted(object sender, object object_0)
		{
			this.hideMsgTips(false);
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return null;
			}
			if (string.IsNullOrEmpty(this.cuUser))
			{
				return null;
			}
			base.get_Dispatcher().BeginInvoke(delegate
			{
				if (this.isVoiceRecordStart)
				{
					return;
				}
				this.isVoiceRecordStart = true;
				this.mVoiceService.IsRecording = true;
			});
			return this.cuUser;
		}
		private object mInputer_mDlgVoiceInputEnd(object sender, object object_0)
		{
			this.mVoiceService.IsRecording = false;
			return null;
		}
		private void mExtralChatButton_ShareLocationButtonClick(object sender, RoutedEventArgs e)
		{
			this.DoShareLocationBtnEvent();
		}
		private void mExtralChatButton_ShareCardClick(object sender, RoutedEventArgs e)
		{
			this.DoShareCardBtnEvent();
		}
		private void mExtralChatButton_CameraCardClick(object sender, RoutedEventArgs e)
		{
			this.DoCameraBtnEvent();
		}
		private void mExtralChatButton_PicButtonClick(object sender, RoutedEventArgs e)
		{
			this.DoImgSendBtnEvent();
			this.mExtralChatButton.Hide();
		}
		private void mExtralChatButton_PicButtonClick1(object sender, RoutedEventArgs e)
		{
			this.DoImgSendBtnEvent1();
		}
		private void ExtraActionBtn_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
		{
			this.mBIsExtraActionCancled = false;
		}
		private void ExtraActionBtn_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
		{
			Log.smethod_5("ChatPage", "ExtraActionBtn_Click");
			if (this.mBIsExtraActionCancled)
			{
				return;
			}
			bool flag = this.mExtralChatButton.IsShowing();
			this.SwitchMode(ChatInputMode.InputDefault, false);
			this.mBIsExtraActionCancled = true;
			if (flag)
			{
				this.mExtralChatButton.Hide();
			}
			else
			{
				this.mExtralChatButton.Show();
			}
			this.mExtralChatButton.Focus();
			this.mExtralChatButton.add_LostFocus(new RoutedEventHandler(this.mExtralChatButton_LostFocus));
		}
		private void ExtraActionBtn_Click(object sender, RoutedEventArgs e)
		{
			Log.smethod_5("ChatPage", "ExtraActionBtn_Click");
			this.hideMsgTips(false);
			if (this.mBIsExtraActionCancled)
			{
				return;
			}
			this.SwitchMode(ChatInputMode.InputDefault, false);
			this.mBIsExtraActionCancled = true;
			this.mExtralChatButton.Switch();
			this.mExtralChatButton.Focus();
			this.mExtralChatButton.add_LostFocus(new RoutedEventHandler(this.mExtralChatButton_LostFocus));
		}
		private void mExtralChatButton_LostFocus(object sender, RoutedEventArgs e)
		{
			object focusedElement = FocusManager.GetFocusedElement();
			if (focusedElement != this.ExtraActionBtn && focusedElement != this.mExtralChatButton.CameraBtn && focusedElement != this.mExtralChatButton.ImgSendBtn && focusedElement != this.mExtralChatButton.ShareCardBtn)
			{
				this.mExtralChatButton.Hide();
			}
			this.mExtralChatButton.remove_LostFocus(new RoutedEventHandler(this.mExtralChatButton_LostFocus));
		}
		private void DoShareLocationBtnEvent()
		{
			this.mExtralChatButton.Hide();
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			if (this.cuUser.EndsWith("@qqim"))
			{
				MMMessageBox.Show(strings.MessageContent_ShareLocatoin_NotSupported, true, "确定");
				return;
			}
			if (this.cuUser.Contains("@bottle"))
			{
				MMMessageBox.Show(strings.Float_Bottle_ShareLocatoin_NotSupported, true, "确定");
				return;
			}
			if (this.containerPage == null)
			{
				return;
			}
			LocationServiceTipPage.GotoThisPage(new object[]
			{
				MapPage.GetMapPageArg(this.GetRootPage<BasePage>(), MapPage.PageType.SendPage, this.cuUser, 30.259497, 120.129798, 16.0, ""),
				"/Source/UI/Chat/Map/MapPage.xaml"
			});
		}
		private void DoCameraBtnEvent()
		{
			this.mExtralChatButton.Hide();
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			this.ChatList.Focus();
			if (this.mCuInputMode == ChatInputMode.InputSmileyMode)
			{
				this.SwitchMode(ChatInputMode.InputDefault, false);
			}
			this.TakePhoto();
		}
		private void DoShareCardBtnEvent()
		{
			this.mExtralChatButton.Hide();
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			if (this.cuUser.EndsWith("@qqim"))
			{
				MMMessageBox.Show(strings.MessageContent_ShareCard_NotSupported, true, "确定");
				return;
			}
			if (this.cuUser.Contains("@bottle"))
			{
				MMMessageBox.Show(strings.Float_Bottle_ShareCard_NotSupported, true, "确定");
				return;
			}
			if (this.containerPage == null)
			{
				return;
			}
			SelectCard.StartSelectCard(this.containerPage.GetRealPage(), this, this.cuUser, SelectCard.SelectCardFromType.fromChatPage);
		}
		private void DoImgSendBtnEvent1()
		{
			this.mExtralChatButton.Hide();
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			this.ChatList.Focus();
			if (this.mCuInputMode == ChatInputMode.InputSmileyMode)
			{
				this.SwitchMode(ChatInputMode.InputDefault, false);
			}
			this.ChooserPicture();
		}
		private void DoImgSendBtnEvent()
		{
			if (!this.isSendEnable)
			{
				MMMessageBox.Show(strings.Plugin_QQOffline_OffTip, true, "确定");
				return;
			}
			this.ChatList.Focus();
			if (this.mCuInputMode == ChatInputMode.InputSmileyMode)
			{
				this.SwitchMode(ChatInputMode.InputDefault, false);
			}
			this.mmmessageBox_0 = MMMessageBox.Show(strings.ChatSendPicDlgTitle, strings.ChatSendPicDlgInfo, true, strings.ChatSendPicDlgTakePhoto, strings.ChatSendPicDlgImgLib);
			this.mmmessageBox_0.ReturnEvent = new DlgReturnEvent(this.SelectPicDlgReturn);
		}
		private void loadCustomSmileys(MMObservableCollection<ChatMsg, ChatListItem> talkList)
		{
			this.playingGifList = new List<CustomSmileyItem>();
			this.allCustomSmileyIds = new List<int>();
			this.IsStartCompleted = false;
			this.LastGifTime = 0L;
			using (IEnumerator<ChatMsg> enumerator = talkList.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					ChatMsg current = enumerator.get_Current();
					if (current.IsCustomSmiley() && !current.isGifRead)
					{
						this.allCustomSmileyIds.Add(current.nMsgLocalID);
					}
				}
			}
			int num = AppInfoHelper.Is256MbDevice() ? 1 : 3;
			if (this.allCustomSmileyIds.get_Count() <= num)
			{
				this.IsStartCompleted = true;
			}
		}
		private void showTooMuchMsgTips(string usrname)
		{
			if (ContactMgr.getUserType(usrname) != ContactMgr.UserType.UserTypeChatRoom)
			{
				return;
			}
			Conversation conversation = StorageMgr.converation.method_0(this.cuUser);
			if (conversation != null && conversation.nUnReadCount > 0)
			{
				if (ChatRoomMgr.GetChatRoomShowTooMuchMsgNotify(usrname, conversation.nUnReadCount))
				{
					this.hideNewMsgTips();
					this.mExtralChatButton.Hide();
					this.tooMuchMsgTips.set_Visibility(0);
					ChatRoomMgr.IncreaseChatRoomTooMuchMsgNotifyNumber(this.cuUser);
				}
				return;
			}
		}
		private void tooMuchMsgTipsGrid_Click(object sender, RoutedEventArgs e)
		{
			ChatRoomMgr.SetChatRoomTooMuchMsgNotifyNumber(this.cuUser, 3);
			MMMessageBox mMMessageBox = MMMessageBox.Show(strings.ChatRoom_Close_Notify_MsgBox, "", true, strings.COM_Yes, strings.COM_No);
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.MsgBoxCloseChatRoomNotifyHandler);
			this.hideTooMuchMsgTips();
		}
		private void hideMsgTips(bool checkTime = false)
		{
			this.hideTooMuchMsgTips();
			if (checkTime && DebugEx.getTimeSpan(this.lastShowNewMsgTipTime) < 2000L)
			{
				return;
			}
			this.hideNewMsgTips();
		}
		private void hideTooMuchMsgTips()
		{
			this.tooMuchMsgTips.set_Visibility(1);
		}
		private void closeTooMuchMsgTips_Click(object sender, RoutedEventArgs e)
		{
			ChatRoomMgr.SetChatRoomTooMuchMsgNotifyNumber(this.cuUser, 3);
			this.hideTooMuchMsgTips();
		}
		public void MsgBoxCloseChatRoomNotifyHandler(DlgReturnEventArg dlgReturnEventArg_0)
		{
			switch (MMMessageBox.GetUserClickResult(dlgReturnEventArg_0))
			{
			case 0:
				ChatRoomMgr.SetModChatRoomNotify(this.cuUser, false);
				MessageBoxManager.ShowToast(strings.ChatRoom_Close_Notify_Toast, 5000, null, true);
				break;
			case 1:
				break;
			default:
				return;
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/ChatPageCtrl.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.RootGrid = (Grid)base.FindName("RootGrid");
			this.ChatTitle = (Grid)base.FindName("ChatTitle");
			this.TitleArea = (StackPanel)base.FindName("TitleArea");
			this.PageTitle = (EmojiText)base.FindName("PageTitle");
			this.ChatNumTitle = (TextBlock)base.FindName("ChatNumTitle");
			this.PeopleListBtn = (CommonImageButton)base.FindName("PeopleListBtn");
			this.QQChatTitle = (Grid)base.FindName("QQChatTitle");
			this.QQTitleArea = (StackPanel)base.FindName("QQTitleArea");
			this.QQLogo = (Image)base.FindName("QQLogo");
			this.QQPageTitle = (EmojiText)base.FindName("QQPageTitle");
			this.PeopleDetailBtn = (CommonImageButton)base.FindName("PeopleDetailBtn");
			this.gridNoFmessageTip = (Grid)base.FindName("gridNoFmessageTip");
			this.MMAudioPlayer = (MediaElement)base.FindName("MMAudioPlayer");
			this.MMMediaPlayer = (MediaElement)base.FindName("MMMediaPlayer");
			this.ChatPanelRoot = (Grid)base.FindName("ChatPanelRoot");
			this.ChatListLayout = (Grid)base.FindName("ChatListLayout");
			this.ChatList = (MMListBox)base.FindName("ChatList");
			this.FootArea = (StackPanel)base.FindName("FootArea");
			this.mInputer = (MMInputer)base.FindName("mInputer");
			this.mExtralChatButton = (ExtralChatButton)base.FindName("mExtralChatButton");
			this.newMsgTips = (Grid)base.FindName("newMsgTips");
			this.content = (SmileyText)base.FindName("content");
			this.total = (TextBlock)base.FindName("total");
			this.tooMuchMsgTips = (Grid)base.FindName("tooMuchMsgTips");
			this.tooMuchMsgTipsGrid = (Grid)base.FindName("tooMuchMsgTipsGrid");
			this.closeTooMuchMsgTips = (Button)base.FindName("closeTooMuchMsgTips");
		}
	}
}
